package com.zzg.springboot.entity;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyColumn;
import javax.persistence.MapKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.zzg.springboot.entity.enumerate.SexEnum;

@Entity
@Table(name="user")
public class UserMap {
	@Id
	@GeneratedValue
	private Long id;
	@Column(name="name")
	private String name;
	@Column(name="pwd")
	private String pwd;
	@Column(name="address")
	private String address;
	@Column(name = "sex")
	@Enumerated(EnumType.ORDINAL) //枚举类型成员属性映射
	private SexEnum sex;
	@Column(name = "birthday")
	@Temporal(TemporalType.TIME) //时间格式类型
	private java.util.Date birthday;
	@Transient //非数据库表的字段的映射,ORM框架将忽略该属性
	private String message;
	
	 @ElementCollection //1.指定集合元素的数据类型
	 @CollectionTable(name = "user_map",joinColumns=@JoinColumn(name="user_id")) //2、指定关联表表名称和关联字段
	 @MapKeyColumn(name = "user_key") //key 取值
	 @Column(name = "user_value")     //value 取值
	 private Map<String, String> others = new HashMap<String, String>();

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public SexEnum getSex() {
		return sex;
	}

	public void setSex(SexEnum sex) {
		this.sex = sex;
	}

	public java.util.Date getBirthday() {
		return birthday;
	}

	public void setBirthday(java.util.Date birthday) {
		this.birthday = birthday;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Map<String, String> getOthers() {
		return others;
	}

	public void setOthers(Map<String, String> others) {
		this.others = others;
	}
	 
	 


}
